﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ggprot;

namespace GGTest
{
    public partial class Parallel : Form
    {
        private GaduProtocol protocol;

        public Parallel(GaduProtocol prot)
        {
            InitializeComponent();

            protocol = prot;

            if (prot.ParallelUsers != null)
                foreach (GGMultiloginItem mli in prot.ParallelUsers)
                {
                    ListViewItem LVI = new ListViewItem(mli.LoginIp.ToString());
                    LVI.SubItems.Add(mli.Flags.ToString());
                    LVI.SubItems.Add(mli.Features.ToString());
                    LVI.SubItems.Add(mli.LoginTime.ToString());
                    LVI.SubItems.Add(mli.ConnId.ToString());
                    LVI.SubItems.Add(mli.Name);

                    listView1.Items.Add(LVI);
                }
        }

        private void rozłączToolStripMenuItem_Click(object sender, EventArgs e)
        {
            protocol.DisconnectParallel(long.Parse(listView1.SelectedItems[0].SubItems[4].Text));
            listView1.Items.Remove(listView1.SelectedItems[0]);
        }

        private void listView1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
                contextMenuStrip1.Show(listView1, listView1.PointToScreen(listView1.PointToClient(e.Location)));
        }
    }
}
